//ONLOAD FUNCTION OF RIALTO JAVASCRIPT API
rialto.onLoad = function (){
//===========
	if (rialto.loaded){
	 return;
	}
	rialto.loaded = true;
	rialto.session.oParameters=rialto.url.getObjectParameter();
	rialto.appearence.initSkin();
	//gebug window
	if (rialto.config.isDebug
		&&  !rialto.config.isTestVersion)  {
		fr = new Dashboard({title:'DEBUG WINDOW'});  
    	initTrace(1,{traceMode:'oneLevel'},null,divTrace.oHtml);
   	}   	
 	__boot ();
}

//ONUNLOAD FUNCTION OF RIALTO JAVASCRIPT API
rialto.onUnLoad = function (){
//===========
	//Release references
	rialto.session.removeAll();
	return true;
}


//------------------------------------------------------------------------
//ATTACH ONLOAD AND UNLOAD EVENT TO THE DOCUMENT
//ria.utils.event.genericAddEvent(window, "DOMContentLoaded", rialto.onLoad);
if (rialtoConfig.userAgentIsIE) {

	if (document.body){
		ria.utils.event.genericAddEvent(document.body, "readystatechange", rialto.onLoad);
	}
	else{
		ria.utils.event.genericAddEvent(document, "readystatechange", rialto.onLoad);
	}
}
else{
	ria.utils.event.genericAddEvent(window, "load", rialto.onLoad);
}
ria.utils.event.genericAddEvent(window, "beforeunload", rialto.onUnLoad);




//SKIN INITIALIZATION (TEST)
rialto.appearence = {};
rialto.appearence.initSkin = function() {
//=========================
	if (!rialto.config.skinList) return;
	rialto.appearence.currentSkin = rialtoConfig.skin || 'standart';
	var cssId =	  rialto.appearence.currentSkin
				+ '_'
				+ rialtoConfig.baseIdCssWithSkin;
	var linkCss = document.getElementById(cssId);
	if (linkCss) linkCss.disabled= false;
	for (var i=0; i < rialtoConfig.skinList.length; i++) {
		var othCssId =	  rialtoConfig.skinList[i]
						+ '_'
						+ rialtoConfig.baseIdCssWithSkin;
		linkCss = document.getElementById(othCssId);
		if (linkCss) linkCss.disabled = (cssId != othCssId); //true;
	} 
}

rialto.appearence.setSkin = function(skin, isForcedUpdate) {
//=========================
	if (!rialto.config.skinList) return;
	traceExec('setSkin '+skin,73);
	if (	!isForcedUpdate
		&&  (skin == rialto.appearence.currentSkin)) return;
	var cssId =	  rialto.appearence.currentSkin
				+ '_'
				+ rialtoConfig.baseIdCssWithSkin;
	//alert('disabled skin : '+cssId);
	document.getElementById(cssId).disabled = true;
	rialto.appearence.currentSkin = skin;
	cssId =	  rialto.appearence.currentSkin
			+ '_'
			+ rialtoConfig.baseIdCssWithSkin;	
	document.getElementById(cssId).disabled = false;
	//alert('enabled skin : '+cssId);
}



//BOOT FUNCTION
function __boot () {
//=============
		

	// boot = instanciation JS obj
		
	//Global size
	widthGlobal=document.body.clientWidth;
	heightGlobal=document.body.clientHeight;
	
	//Cancel selection in the page
	document.onselectstart=function(){return false;};
//	document.onselectstart=function(){return true;};
	//document.body.style.backgroundColor="#CCCCCC";   

	//This is to close contextual menu
	document.onclick =  function(){            
	    if (objMenuCont.prototype.menuActif){objMenuCont.prototype.menuActif.masqueMenu();}        
	}

	document.oncontextmenu =  function(){            
	    if (objMenuCont.prototype.menuActif){objMenuCont.prototype.menuActif.masqueMenu();}        
	    return false;
	}
	
	//document.body.style.border="5px solid red";
	document.body.style.overflow='hidden';
	
	//This is to add a top level rialto container like with reccord and remove function
	document.body.arrChild=new Array();
	document.body.oRia=document.body;
	document.body.id="body";
	document.body.isContainer=true;
	document.body.record = rialto.widget.AbstractContainer.prototype.record;
	document.body.removeContents = rialto.widget.AbstractContainer.prototype.removeContents;
	document.body.updateToContent = function(){};
	document.body.resizeChilds = rialto.widget.AbstractContainer.prototype.resizeChilds;
	document.body.remove=function(){
		document.body.oRia=null;
		document.onselectstart=null;
		document.onclick=null;
		document.oncontextmenu=null;
		//document.body.arrChild=null;
		document.body.record=null;
		document.body.removeContents = null;
		document.body.updateToContent = null;
		document.body.resizeChilds=null;
	}
    //document.body.oRia=new rialto.widget.AbstractContainer({});
    //masque pour les pop up
    	
	rialto.session.masque = document.createElement('DIV');        
    rialto.session.masque.style.display = 'none';
    rialto.session.masque.style.width =  '100%';
    rialto.session.masque.style.height = '100%';        
    rialto.session.masque.style.zIndex = 10000;        
    window.document.body.appendChild(rialto.session.masque);
    //masque pour les pop up
    rialto.session.masquePopupTop = document.createElement('DIV');        
    rialto.session.masquePopupTop.style.display = 'none';
    rialto.session.masquePopupTop.style.width =  '100%';
    rialto.session.masquePopupTop.style.height = '100%';        
    rialto.session.masquePopupTop.style.zIndex = 10000;        
    window.document.body.appendChild(rialto.session.masquePopupTop);

   	


	/********************GESTION DU RESIZE****************************/       
	window.onresize=function(){     
	    var over=document.body.style.overflow;
	    document.body.style.overflow='hidden';
	    document.body.resizeChilds();       
  	    document.body.style.overflow=over;
	}        
	
	//var t1=(new Date()).getTime();
	//alert("load en "+(t1-rialtoConfig.t0) + " msec");
}
	